package lambda_expression.stream;

import lambda_expression.method_reference.Employee;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.OptionalDouble;

public class MaxMinStreamTest {

    public static void main(String[] args) {
        List<Employee> employeeList = new ArrayList<Employee>();
        employeeList.add(new Employee(1, "ABC", 100, 1120.0));
        employeeList.add(new Employee(2, "DEF", 200, 220.0));
        employeeList.add(new Employee(3, "QWE", 300, 330.0));
        employeeList.add(new Employee(4, "RTY", 400, 9999.0));
        employeeList.add(new Employee(4, "POI", 200, 10.0));
        employeeList.add(new Employee(4, "UYT", 300, 665.0));

        OptionalDouble maxSalary = employeeList.stream()
                .mapToDouble(Employee::getSalary)
                .max();

        System.out.println("maxSalary = " + maxSalary);

        OptionalDouble minSalary = employeeList.stream()
                .mapToDouble(Employee::getSalary)
                .min();

        System.out.println("minSalary = " + minSalary);

        long count = employeeList.stream()
                .count();

        System.out.println("count = " + count);

    }
}
